package com.lm.shop.order.config;

import com.lm.shop.order.rule.MyRule;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author lsk
 * @version 1.0.0
 * @ClassName MyRibbonConfig.java
 * @Description ribbon 配置
 * @createTime 2022年10月24日 16:35:00
 */
@Configuration
public class MyRibbonConfig {

    /**
     * @title restTemplate
     * @description 使用ribbon负载均衡
     * @author lsk
     * @updateTime 2022/10/24 16:42
     * @return: org.springframework.web.client.RestTemplate
     * @throws
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return  new RestTemplate();
    }


    /**
     * @title iRule
     * @description 配置负载均衡策略
     * @author lsk
     * @updateTime 2022/10/24 16:39
     * @return: com.netflix.loadbalancer.IRule
     * @throws
     */
    @Bean
    public IRule iRule(){
        return new RoundRobinRule();
    }
}
